package com.nuanshui.heatedloan.web.accountbill;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSON;
import com.nuanshui.framework.security.DESC;
import com.nuanshui.heatedloan.constant.GlobalParam;
import com.nuanshui.heatedloan.credit.facade.CustomerIdCardInfoService;
import com.nuanshui.heatedloan.credit.facade.PayOrderInfoService;
import com.nuanshui.heatedloan.credit.vo.CustomerIdCardInfoVO;
import com.nuanshui.heatedloan.credit.vo.PayOrderInfoVO;
import com.nuanshui.heatedloan.fund.constant.AccountBillSubType;
import com.nuanshui.heatedloan.fund.facade.UserAccountBillService;
import com.nuanshui.heatedloan.fund.form.UserBillInfoForm;
import com.nuanshui.heatedloan.fund.vo.UserBillInfoVO;
import com.nuanshui.heatedloan.pageable.Pager;
import com.nuanshui.heatedloan.web.ApiController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zss
 * @date 2017/8/2 20:16
 * @description
 * @Since
 */
@RestController
@RequestMapping("/cms/manage/paybill")
public class PayBillController extends ApiController {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Reference(url= GlobalParam.FUND_DUBBO_SERVER,timeout=GlobalParam.DUBBO_SERVER_TIME_OUT,version = GlobalParam.FUND_DUBBO_SERVER_VERSION)
    private UserAccountBillService userAccountBillService;

    @RequestMapping("/list")
    public String paylist(Pager<UserBillInfoVO> pager ,String query){
        UserBillInfoForm userBillInfoForm = JSON.parseObject(query, UserBillInfoForm.class);
        userBillInfoForm.setSubType(String.valueOf(AccountBillSubType.TYPE_PAY));
        pager =userAccountBillService.loadPaylist(pager,userBillInfoForm);
        Map<String, Object> resultMap = pager.asHashMap();
        resultMap = userAccountBillService.loadCount(userBillInfoForm,resultMap);
        resultMap = userAccountBillService.loadSum(userBillInfoForm,resultMap);
        return  success(resultMap);
    }

}
